<%@page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/common/taglib.jsp"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>${page.pageName}</title>
<%@include file="/common/public.jsp"%>
<link rel="stylesheet" type="text/css" href="${ctx}/css/main.css">
<link rel="stylesheet" type="text/css" href="${ctx}/css/query.css">
<script type="text/javascript" src="${ctx}/js/editarea/edit_area_full.js"></script>
<script type="text/javascript">
window.Parent = window.dialogArguments;
window.Action = {};
Action.save = function(){
	var queryConfig = codeEditor.getValue("queryConfig");
	jQuery("#queryConfig").val(queryConfig);
	jQuery("form:first").submit();
};
Action.complete = function( id ){
	if( jQuery("#id").val() == ""){
		jQuery("#id").val(id);//新增完成获取ID
		Parent["Action"].addQueryConfig({value:id,text:jQuery("#queryName").val()});
	}
};
Action.test = function(){
	var id = jQuery("#id").val();
	var url = "${ctx}/page/config/queryConfigTest.do?id=" + id;
	Tools.window({width:1000,height:600,url:url});
};
jQuery( function(){
	if( "" == "${bean.queryId}"){
		var pageName = jQuery("#pageName",Parent.document).val();
		jQuery("#queryName").val(pageName);
	}
	// 初始化编辑器
	codeEditor.init({
		id: "queryConfig"		
		,start_highlight: true
		,allow_resize: "both"
		,allow_toggle: true
		,word_wrap: false
		,language: "zh"
		,syntax: "sql"	
	});
});
</script>
</head>
<body>
<e:form name="EditForm" action="/page/config/queryConfigSave.do">
<e:hidden name="id" value="${bean.queryId}"/>
<table class="etable">
	<tr>
		<td class="tl">查询名称：</td>
		<td class="tc">
			<e:text name="queryName" className="input" validate="{required:true,maxlength:128}" value="${bean.queryName}">
				<e:param name="defValue" value=""/>
			</e:text>
		</td>
		<td class="tl">查询编码：</td>
		<td class="tc">
			<e:text name="queryCode" className="input" validate="{required:true,maxlength:128}" value="${bean.queryCode}">
				<e:param name="defValue" value=""/>
			</e:text>
		</td>
	</tr>
	<tr>
		<td class="tl">查询类型：</td>
		<td class="tc">
			<e:select name="queryTypeId" className="input" validate="{required:true,maxlength:32}" value="${bean.queryTypeId}">
				<e:param name="source" value="sql:select A.QUERY_TYPE_ID VALUE , A.QUERY_TYPE_NAME TEXT from QUERY_TYPE A where STATE='A'"/>
				<e:param name="defValue" value="1"/>
			</e:select>
		</td>
		<td class="tl">查询分类：</td>
		<td class="tc">
			<e:select name="configTypeId" className="input" validate="{required:true,maxlength:32}" value="${bean.configTypeId}">
				<e:param name="source" value="sql:select A.CONFIG_TYPE_ID VALUE , A.CONFIG_TYPE_NAME TEXT from CONFIG_TYPE A where STATE='A'"/>
				<e:param name="defValue" value="${param.configTypeId}"/>
			</e:select>
		</td>
	</tr>
	<tr>
		<td class="tl">数据源：</td>
		<td class="tc">
			<e:select name="sourceId" className="input"  validate="{required:true,maxlength:32}"  value="${bean.sourceId}">
				<e:param name="source" value="sql:select A.SOURCE_ID VALUE , A.SOURCE_NAME TEXT from SOURCE_INFO A where STATE='A'"/>
				<e:param name="defValue" value="1"/>
			</e:select>
		</td>
	</tr>
	<tr>
		<td class="tl">查询说明：</td>
		<td class="tc" colspan="3"><e:textarea name="queryDesc" style="width:100%; height:50px" validate="{required:false}" value="${page.queryDesc}"/></td>
	</tr>
	<tr>
		<td class="tl">查询配置：</td>
		<td class="tc" colspan="3">
			<e:textarea name="queryConfig" style="width:720px; height:460px" value="${bean.queryConfig}" validate="{required:true}"/>
		</td>
	</tr>
	<tr>
		<td align="center" colspan="4" height="30">
		<input id="SaveButton" type="button" class="btn_orange_b2" value="保 存" onClick="Action.save()"/>
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<input id="SaveButton" type="button" class="btn_orange_b2" value="测 试" onClick="Action.test()"/>
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<input id="SaveButton" type="button" class="btn_blue_b2" value="关 闭" onClick="window.close()"/>
		</td>
	</tr>
</table>
</e:form>
</body>
</html>